import React from "react";
// 类组件的传值
class Child extends React.Component {
  state = {
    count: 0
  }
  clickHandler = () => {
    this.props.fn(this.state.count)
  }
  render() {
    console.log(this.props)
    return (
      <div>
        {/* props是只读的,不能修改 ,如果写了构造函数,必须写super(props)*/}
        来自父组件的参数:{this.props.name} 和 {this.props.age}
        <button onClick={this.clickHandler}>点击调用父组件传过来的函数,并将信息传回父组件</button>
       </div>
    );
  }
}

export default Child